import request from "@/request/index";

//请求1:获取医院分页列表
export const reqHosListByPage = (page = 1, limit = 5,data?:typeDataReq) => {
  return request.get<any, typeHosListByPageResponse>(
    `/hosp/hospital/${page}/${limit}`,{params:data}
  );
};
//类型1: 医院分页列表返回值类型
export interface typeHosListByPageResponse {
  content: typeHosListByPageContent[]; //类型1-1
  pageable: {
    sort: {
      sorted: true;
      unsorted: false;
      empty: false;
    };
    pageNumber: 0;
    pageSize: 1;
    offset: 0;
    paged: true;
    unpaged: false;
  };
  totalPages: number;
  totalElements: number;
  last: boolean;
  first: boolean;
  sort: {
    sorted: true;
    unsorted: false;
    empty: false;
  };
  numberOfElements: number;
  size: number;
  number: number;
  empty: boolean;
}
//类型1-1:医院分页列表 content类型
export interface typeHosListByPageContent {
  id: string;
  createTime: string;
  updateTime: string;
  isDeleted: number;
  param: {
    hostypeString: string;
    fullAddress: string;
  };
  hoscode: string;
  hosname: string;
  hostype: string;
  provinceCode: string;
  cityCode: string;
  districtCode: string;
  address: string;
  logoData: string;
  intro: null;
  route: string;
  status: number;
  bookingRule: typeBookingRule|null;
}
export interface typeBookingRule{
  cycle: number;
  releaseTime: string;
  stopTime: string;
  quitDay: number;
  quitTime: string;
  rule: string[];
}
//类型1-2:请求参data类型
export interface typeDataReq{
  hostype:string,
  districtCode:string
}
/* ******************************************* */
//请求2:获取医院等级 (参数定死的垃圾接口,文档也不给纯靠猜)
export const reqHosLevel = (parentId = 10000) => {
  return request.get<any,typeHosLevelItem[]>(`/cmn/dict/findByParentId/${parentId}`);
};
//类型2:获取医院等级返回值 每项类型
export interface typeHosLevelItem {
  id: number;
  createTime: string;
  updateTime: string;
  isDeleted: number;
  param: object;
  parentId: number;
  name: string;
  value: string;
  dictCode: string;
  hasChildren: boolean;
}

/* ******************************************* */
//请求3:获取北京地区列表  (参数定死的垃圾接口,文档也不给纯靠猜)
export const reqHosPlace = (dictCode = `Beijin`) =>{
  return request.get<any,typeHosPlaceResponse>(`/cmn/dict/findByDictCode/${dictCode}`)
}
//类型3:北京地区列表返回值类型 (同类型2)
export type typeHosPlaceResponse = typeHosLevelItem[]
/* ******************************************* */

//请求4:根据(输入的)医院名称获取医院列表 (支持模糊搜索)
export const reqFindByHosname = (hosname:string) =>{
  return request.get<any,typeHosListByPageContent[]>(`/hosp/hospital/findByHosname/${hosname}`)
}